
<%@ include file="/common/taglibs.jsp"%>
<!--分页查询共用的页面-->
<%@ include file="/common/common.jsp"%>

<%@ include file="/common/dateUtil.jsp"%>
<%@ page language="java" pageEncoding="UTF-8"%>

<script>

	function deleteAlarmConfigConfirm()
	{
        $.messager.confirm('确认','确定要删除此报警配置?',function(r){
            if (r){
                deleteAlarmConfig();
            }
            return r;
        });

	}
	function deleteAlarmConfig()
	{
	    var actionUrl = "<%=ApplicationPath%>/alarmConfig/delete.action?entityId=${entity.entityId}";
        $.getJSON(actionUrl, function(result){
            if (result.success == true) {
                $("#queryGrid").datagrid('load');
                //$("#" + gridId).trigger("reloadGrid");
                //$("#dataTable"). dataTable().fnDraw();
                //删除成功后，刷新主窗口数据
                window.parent.refreshTabPage();
                $.messager.alert('提示',"删除成功!");
                window.parent.closeCommandWindow();
            }
            else
                $.messager.alert('提示',"无法删除! 错误原因：" + result.message);
        });
	}


    /**
     * 视频存储器下拉框多选时触发
     * @param selectedValues
     */
    function onVideoMonitorChannelComboChecked(selectedValues)
    {
        $("#videoMonitorChannels").val(selectedValues);
    }


    /**
     * 视频存储器下拉框多选时触发
     * @param selectedValues
     */
    function onTakePictureChannelComboChecked(selectedValues)
    {
        $("#takePictureChannels").val(selectedValues);
    }


$().ready(function() {
		 $("#EntityForm").validate();


		 //初始化视频监控联动通道多选下拉框
    $("#videoMonitorChannelCombo").initComboTree({
        params: {category: "VideoChannel"},
        onCheck: onVideoMonitorChannelComboChecked,
        selectedValues: "${entity.videoMonitorChannels}"
    });
    //初始化拍照报警联动通道多选下拉框
    $("#takePictureChannelCombo").initComboTree({
        params: {category: "VideoChannel"},
        onCheck: onTakePictureChannelComboChecked,
        selectedValues: "${entity.takePictureChannels}"
    });
		 
	 $("#alarmSource").lookup({category:"AlarmSource", selectedValue:"${entity.alarmSource}"});
		 var mesasge = "${message}";
			if(mesasge.length > 0)
			{
				//保存成功后，刷新主窗口数据
				 window.parent.refreshTabPage();
			}
});
</script>
 <BODY>
	<form id="EntityForm" name="EntityForm" 
			action="<%=ApplicationPath%>/alarmConfig/saveConfig.action" method="POST">
				<input type="hidden"  name="entityId"
					value="${entity.entityId}"/>
		<input type="hidden" id="videoMonitorChannels" name="videoMonitorChannels"
			   value="${entity.videoMonitorChannels}"/>
		<input type="hidden" id="takePictureChannels" name="takePictureChannels"
			   value="${entity.takePictureChannels}"/>
  <table width="100%"  class="TableBlock">
			<tr>
				<td colspan="4" style="font-weight: bold; background: #EFEFEF;">
					基本信息<span class="MessageFromServer">${message}</span></td>
			</tr>
			
			<tr>
				<td align=right>报警类型名称:</td>
				<td align="left" colspan=3><input type="text" name="name" size="20"  value="${entity.name}" id="name" class="required"  /></td>

				
			</tr>
			<tr>
                 <td align=right  width="20%">报警编码:</td>
				<td align="left"  width="30%">
				  <input type="text" name="alarmType" size="20"  value="${entity.alarmType}" id="alarmType" class="required"  />
				</td>
				<td align="right"  width="20%">报警来源:</td>
						<td align="left" width="30%"><select  id="alarmSource" 		name="alarmSource"  class="required" > 
						</select>
						</td>
			</tr>
	  <tr>
		  <td align=right  width="20%">实时音视频监控联动:</td>
		  <td>

			  <select id="videoMonitorChannelCombo"  style="width: 150px;" name="videoMonitorChannelCombo" >
			  </select>
		  </td><td align="right">拍照联动
		  :</td>
		  <td>

			  <select id="takePictureChannelCombo"  style="width: 150px;" name="takePictureChannelCombo" >
			  </select>
		  </td>
	  </tr>
			
			<tr>
				<td  align=right>启用:</td>
				<td align="left" colspan=3>				
				   <input type="checkbox" id="alarmConfig_${entity.entityId}" name="enabled" value="true"
				    <c:if test="${entity.enabled==true}">
					checked
					</c:if>
				   /> 报警启用&nbsp;
				   <input type="checkbox" id="alarmConfig_${entity.entityId}" name="soundEnabled" value="true"
				   <c:if test="${entity.soundEnabled==true}">
				   checked
					</c:if>
				   /> 报警声音&nbsp;
				   <input type="checkbox" id="alarmConfig_${entity.entityId}" name="popupEnabled" value="true"
						 <c:if test="${entity.popupEnabled==true}">
				         checked
					</c:if>
				   />报警弹窗&nbsp;
				   <input type="checkbox" id="alarmConfig_${entity.entityId}" name="statisticEnabled" value="true"
				   
						 <c:if test="${entity.statisticEnabled==true}">
				         checked
					</c:if>
                    />报警时长统计&nbsp;
               </td>
			  
			</tr>
						
			<tr>
						<td colspan="4" align="center">
							<div align="center">

								<button type="submit" class="button green medium" ><i class="fa fa-check" style="margin-right:3px;"></i> 保存</button>

								<button id="btnDel" type="button" class="button red medium" onclick="deleteAlarmConfigConfirm();"><i class="fa fa-close" style="margin-right:3px;"></i> 删除</button>
							</div></td>
					</tr>
			
		
		</table>
 </BODY>
</HTML>
